/**
 * Copyright (C) 2018-2021
 * All rights reserved, Designed By www.yixiang.co

 */
package co.yixiang.modules.user.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.domain.BaseDomain;
import co.yixiang.modules.user.service.dto.WechatUserDto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.*;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
* @author hupeng
* @date 2020-05-12
*/

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString
@TableName(value = "yx_user",autoResultMap = true)
public class YxUser extends BaseDomain {

    /** 用户id */
    @TableId(value = "uid", type = IdType.AUTO)
    private Long uid;


    /** 用户账户(跟accout一样) */
    private String username;




    /** 用户密码（跟pwd） */
    private String password;



    /** 真实姓名 */
    private String realName;


    /** 生日 */
    private Integer birthday;


    /** 身份证号码 */
    private String cardId;


    /** 用户备注 */
    private String mark;


    /** 合伙人id */
    private Integer partnerId;


    /** 用户分组id */
    private Integer groupId;


    /** 用户昵称 */
    private String nickname;


    /** 用户头像 */
    private String avatar;


    /** 手机号码 */
    private String phone;



    /** 添加ip */
    private String addIp;



    /** 最后一次登录ip */
    private String lastIp;


    /** 用户余额 */
    private BigDecimal nowMoney;


    /** 佣金金额 */
    private BigDecimal brokeragePrice;


    /** 用户剩余积分 */
    private BigDecimal integral;


    /** 连续签到天数 */
    private Integer signNum;


    /** 1为正常，0为禁止 */
    private Integer status;


    /** 等级 */
    private Integer level;


    /** 推广元id */
    private Long spreadUid;


    /** 推广员关联时间 */
    private Date spreadTime;


    /** 用户类型 */
    private String userType;


    /** 是否为推广员 */
    private Integer isPromoter;


    /** 用户购买次数 */
    private Integer payCount;


    /** 下级人数 */
    private Integer spreadCount;



    /** 详细地址 */
    private String addres;


    /** 管理员编号  */
    private Integer adminid;


    /** 用户登陆类型，h5,wechat,routine */
    private String loginType;

    /** 微信用户json信息 */
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private WechatUserDto wxProfile;

    public static YxUserBuilder builder() {
        return new YxUserBuilder();
    }


    public void copy(YxUser source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static class YxUserBuilder {
        private Long uid;
        private String username;
        private String password;
        private String realName;
        private Integer birthday;
        private String cardId;
        private String mark;
        private Integer partnerId;
        private Integer groupId;
        private String nickname;
        private String avatar;
        private String phone;
        private String addIp;
        private String lastIp;
        private BigDecimal nowMoney;
        private BigDecimal brokeragePrice;
        private BigDecimal integral;
        private Integer signNum;
        private Integer status;
        private Integer level;
        private Long spreadUid;
        private Date spreadTime;
        private String userType;
        private Integer isPromoter;
        private Integer payCount;
        private Integer spreadCount;
        private String addres;
        private Integer adminid;
        private String loginType;
        private WechatUserDto wxProfile;

        YxUserBuilder() {
        }

        public YxUserBuilder uid(Long uid) {
            this.uid = uid;
            return this;
        }

        public YxUserBuilder username(String username) {
            this.username = username;
            return this;
        }

        public YxUserBuilder password(String password) {
            this.password = password;
            return this;
        }

        public YxUserBuilder realName(String realName) {
            this.realName = realName;
            return this;
        }

        public YxUserBuilder birthday(Integer birthday) {
            this.birthday = birthday;
            return this;
        }

        public YxUserBuilder cardId(String cardId) {
            this.cardId = cardId;
            return this;
        }

        public YxUserBuilder mark(String mark) {
            this.mark = mark;
            return this;
        }

        public YxUserBuilder partnerId(Integer partnerId) {
            this.partnerId = partnerId;
            return this;
        }

        public YxUserBuilder groupId(Integer groupId) {
            this.groupId = groupId;
            return this;
        }

        public YxUserBuilder nickname(String nickname) {
            this.nickname = nickname;
            return this;
        }

        public YxUserBuilder avatar(String avatar) {
            this.avatar = avatar;
            return this;
        }

        public YxUserBuilder phone(String phone) {
            this.phone = phone;
            return this;
        }

        public YxUserBuilder addIp(String addIp) {
            this.addIp = addIp;
            return this;
        }

        public YxUserBuilder lastIp(String lastIp) {
            this.lastIp = lastIp;
            return this;
        }

        public YxUserBuilder nowMoney(BigDecimal nowMoney) {
            this.nowMoney = nowMoney;
            return this;
        }

        public YxUserBuilder brokeragePrice(BigDecimal brokeragePrice) {
            this.brokeragePrice = brokeragePrice;
            return this;
        }

        public YxUserBuilder integral(BigDecimal integral) {
            this.integral = integral;
            return this;
        }

        public YxUserBuilder signNum(Integer signNum) {
            this.signNum = signNum;
            return this;
        }

        public YxUserBuilder status(Integer status) {
            this.status = status;
            return this;
        }

        public YxUserBuilder level(Integer level) {
            this.level = level;
            return this;
        }

        public YxUserBuilder spreadUid(Long spreadUid) {
            this.spreadUid = spreadUid;
            return this;
        }

        public YxUserBuilder spreadTime(Date spreadTime) {
            this.spreadTime = spreadTime;
            return this;
        }

        public YxUserBuilder userType(String userType) {
            this.userType = userType;
            return this;
        }

        public YxUserBuilder isPromoter(Integer isPromoter) {
            this.isPromoter = isPromoter;
            return this;
        }

        public YxUserBuilder payCount(Integer payCount) {
            this.payCount = payCount;
            return this;
        }

        public YxUserBuilder spreadCount(Integer spreadCount) {
            this.spreadCount = spreadCount;
            return this;
        }

        public YxUserBuilder addres(String addres) {
            this.addres = addres;
            return this;
        }

        public YxUserBuilder adminid(Integer adminid) {
            this.adminid = adminid;
            return this;
        }

        public YxUserBuilder loginType(String loginType) {
            this.loginType = loginType;
            return this;
        }

        public YxUserBuilder wxProfile(WechatUserDto wxProfile) {
            this.wxProfile = wxProfile;
            return this;
        }

        public YxUser build() {
            return new YxUser(uid, username, password, realName, birthday, cardId, mark, partnerId, groupId, nickname, avatar, phone, addIp, lastIp, nowMoney, brokeragePrice, integral, signNum, status, level, spreadUid, spreadTime, userType, isPromoter, payCount, spreadCount, addres, adminid, loginType, wxProfile);
        }

        public String toString() {
            return "YxUser.YxUserBuilder(uid=" + this.uid + ", username=" + this.username + ", password=" + this.password + ", realName=" + this.realName + ", birthday=" + this.birthday + ", cardId=" + this.cardId + ", mark=" + this.mark + ", partnerId=" + this.partnerId + ", groupId=" + this.groupId + ", nickname=" + this.nickname + ", avatar=" + this.avatar + ", phone=" + this.phone + ", addIp=" + this.addIp + ", lastIp=" + this.lastIp + ", nowMoney=" + this.nowMoney + ", brokeragePrice=" + this.brokeragePrice + ", integral=" + this.integral + ", signNum=" + this.signNum + ", status=" + this.status + ", level=" + this.level + ", spreadUid=" + this.spreadUid + ", spreadTime=" + this.spreadTime + ", userType=" + this.userType + ", isPromoter=" + this.isPromoter + ", payCount=" + this.payCount + ", spreadCount=" + this.spreadCount + ", addres=" + this.addres + ", adminid=" + this.adminid + ", loginType=" + this.loginType + ", wxProfile=" + this.wxProfile + ")";
        }
    }
}
